package com.itheima.service.cargo.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.cargo.ShippingOrderDao;
import com.itheima.domain.cargo.ShippingOrder;
import com.itheima.domain.cargo.ShippingOrderExample;
import com.itheima.service.cargo.ShippingOrderService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@Service
public class ShippingOrderServiceImpl implements ShippingOrderService {
    @Autowired
    private ShippingOrderDao shippingOrderDao;
    @Override
    public ShippingOrder findById(String id) {
        return shippingOrderDao.selectByPrimaryKey(id);
    }

    @Override
    public void save(ShippingOrder shippingOrder) {
        shippingOrderDao.insertSelective(shippingOrder);
    }

    @Override
    public void update(ShippingOrder shippingOrder) {
        shippingOrderDao.updateByPrimaryKeySelective(shippingOrder);
    }

    @Override
    public void delete(String id) {
        shippingOrderDao.deleteByPrimaryKey(id);
    }

    @Override
    public PageInfo findByPage(int pageNum, int pageSize, ShippingOrderExample example) {
        PageHelper.startPage(pageNum,pageSize);
        List<ShippingOrder> list = shippingOrderDao.selectByExample(example);
        return new PageInfo(list);
    }
}
